# -*- coding: utf-8 -*-
# FileName:     round_widget.py
# time:         22/11/22 022 下午 4:03
# Author:       Zhou Hang
# Description:  I don't want to write
import sys

from PyQt5.QtCore import Qt, QPoint
from PyQt5.QtGui import QPainter, QMouseEvent, QColor
from PyQt5.QtWidgets import QWidget, QLabel, QApplication

from src.custom_control.movable_widget import MovableWidget


class RoundWidget(MovableWidget):
    """圆角边框类，带有鼠标拖动功能"""
    def __init__(self, parent=None):
        super(RoundWidget, self).__init__(parent)
        self.padding = 5  # 设置边距
        self.round_width = 20

    def paintEvent(self, event):
        # 圆角
        pat = QPainter(self)
        pat.setRenderHint(pat.Antialiasing)  # 抗锯齿
        pat.setBrush(QColor(49, 54, 59))  # 仅仅适合qt_material中的dark_pink.xml系列主题
        pat.setPen(Qt.transparent)

        rect = self.rect()
        # 设置矩形距离边框的距离
        rect.setLeft(self.padding)
        rect.setTop(self.padding)
        rect.setWidth(rect.width() - self.padding)
        rect.setHeight(rect.height() - self.padding)
        pat.drawRoundedRect(rect, self.round_width, self.round_width)


class TestWindow(RoundWidget):
    """测试窗口"""
    def __init__(self, parent=None):
        super(TestWindow, self).__init__(parent)
        self.resize(400, 400)
        label = QLabel('123456789', self)
        label.move(50, 10)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    t = TestWindow()
    # t = RoundImage('./Asset/new_icons/close.png')
    t.show()
    app.exec_()

